/* analysis Table 3 */
/* run two times: before and after running 3.recodes and analysis dataset */
proc freq data=taxes; tables vignet; run; 

/* dependent variables */
proc corr data=taxes alpha; var decision_acceptance policy_fairness procedure_fairness interest_considered; 
proc corr data=taxes alpha; var decision_acceptance policy_fairness; 
proc corr data=taxes alpha; var procedure_fairness interest_considered; 
proc corr data=taxes alpha; var acceptpo acceptpr; run;

/* variable H1; see recodes line 14-25 and two previous code-files */
proc freq data=taxes; tables autobezit autobezit2; run;

/* models revised paper */
/* MODELS H1a and H1b, Table 4 */
proc glm data=taxes;
 class vignet(ref='control') autobezit2(ref=first);
 model acceptpo = autobezit2/solution effectsize alpha=0.05;
 output out=fmodel1 predicted=policy_predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm r=residuals student=student; 
 
proc glm data=taxes;
 class vignet(ref='control') autobezit2(ref=first);
 model acceptpr = autobezit2/solution effectsize alpha=0.05;
 output out=fmodel2 predicted=procedure_predicted lcl=lcl lclm=lclm ucl=ucl uclm=uclm r=residuals student=student; 
run;

/* Figure 1 and Table 5 */
/* merging the two datasets with predicted values */
data fmodel3 (keep=policy_predicted    responseID); set fmodel3; 
data fmodel4 (keep=procedure_predicted responseID); set fmodel4; 
proc sort data=fmodel3; by responseid; 
proc sort data=fmodel4; by responseid; 
proc sort data=taxes  ; by responseid; 
data taxes2;
 merge fmodel3 fmodel4 taxes;
 by responseid;
run;

proc sort data=fmodel3; by autobezit2;
proc sgpanel data=fmodel3;
    panelby autobezit2 / columns=3 onepanel novarname;
    scatter x=vignet y=policy_predicted/ 
        yerrorlower=LowerCFI 
        yerrorupper=UpperCFI
        markerattrs=(symbol=CircleFilled color=blue size=9);
    series x=vignet y=policy_predicted / lineattrs=(color=blue thickness=2);
    colaxis discreteorder=data label="Conditions";
    rowaxis label="Predicted Policy Acceptance";
run;

/* Table 5 */
/* top row and col table 5 class altpro and altpol */
proc means data=taxes2 mean std maxdec=2 n; 
var procedure_predicted policy_predicted; class altpro ; 
proc means data=taxes2 mean std maxdec=2 n; 
var procedure_predicted policy_predicted; class altpol ; 
/* class altpol and altpro */
proc means data=taxes2 mean std maxdec=2 n; 
var procedure_predicted policy_predicted; class altpro altpol; 
run;

/* test H3a */
proc freq; tables altpol*altpro/chisq; 
/* test H3b */
proc freq data=taxes2; tables test2*altpro/chisq; 
proc sort data=taxes2; by altpol;
proc freq data=taxes2; tables test2*altpro/chisq; by altpol; 

/* additional tests last paragraph empirical section */
proc freq; tables propuni*altpro/chisq ; by altpol;
proc freq; tables consult*altpro/chisq ; by altpol;
run;



